home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00010_Cell parent.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  1.8 KB  |  57 lines

  1. property cell, adjacentList, cellType, Xloc, Yloc, tileType, tileNum, horizValue, vertValue, startTileNum, startTileType, connector
  2. global gSimObject
  3.  
  4. on birth me, cellNum, type, x, y, hVal, vVal
  5.   set cell to cellNum
  6.   set cellType to type
  7.   set startTileNum to 0
  8.   set tileNum to startTileNum
  9.   set startTileType to #BG
  10.   set tileType to startTileType
  11.   set Xloc to x
  12.   set Yloc to y
  13.   set horizValue to hVal
  14.   set vertValue to vVal
  15.   set connector to 0
  16.   initAdjacentList()
  17.   return me
  18. end
  19.  
  20. on initAdjacentList me
  21.   set adjacentList to []
  22.   repeat with adjVector in getProp(the adjList of gSimObject, cellType)
  23.     add(adjacentList, adjVector)
  24.   end repeat
  25. end
  26.  
  27. on saveCell me
  28.   repeat with propName in [tileType, startTileType]
  29.     set cellData to cellData & string(getPos(the cellTypeList of gSimObject, propName)) & ","
  30.   end repeat
  31.   repeat with propNum in [tileNum, startTileNum]
  32.     set cellData to cellData & string(propNum) & ","
  33.   end repeat
  34.   set cellData to cellData & string(connector) & ","
  35.   set cellData to cellData & string(count(adjacentList)) & ","
  36.   if count(adjacentList) > 0 then
  37.     repeat with adj in adjacentList
  38.       set cellData to cellData & string(getPos(the arrowList of gSimObject, adj)) & ","
  39.     end repeat
  40.   end if
  41.   set cellData to char 1 to length(cellData) - 1 of cellData
  42.   return cellData
  43. end
  44.  
  45. on loadCell me
  46.   set tileType to getAt(the cellTypeList of gSimObject, readData(gSimObject))
  47.   set startTileType to getAt(the cellTypeList of gSimObject, readData(gSimObject))
  48.   set tileNum to readData(gSimObject)
  49.   set startTileNum to readData(gSimObject)
  50.   set connector to readData(gSimObject)
  51.   set adjListLength to readData(gSimObject)
  52.   set adjacentList to []
  53.   repeat with x = 1 to adjListLength
  54.     add(adjacentList, getAt(the arrowList of gSimObject, readData(gSimObject)))
  55.   end repeat
  56. end
  57.